package top.fzqblog.music.util;

import android.app.DownloadManager;
import android.content.Context;
import android.net.Uri;

/**
 * Created by 抽离 on 2017/11/3 0003.
 */

public class DownloadUtil {

    public static void download(Context mContext, String downloadUrl, String fileName){
        //创建下载任务,downloadUrl就是下载链接
        DownloadManager.Request request = new DownloadManager.Request(Uri.parse(downloadUrl));
//指定下载路径和下载文件名
        request.setDestinationInExternalPublicDir("/download/", fileName);
//获取下载管理器
        DownloadManager downloadManager= (DownloadManager) mContext.getSystemService(Context.DOWNLOAD_SERVICE);
//将下载任务加入下载队列，否则不会进行下载
        downloadManager.enqueue(request);
    }
}
